<?php

namespace app\event;

use think\response\View;
use think\facade\Request;

class ReadHtml extends View
{

    public function handle($params)
    {
        self::HTML_FILE_NAME();
        die(HTML_FILE_NAME);
    }

    static function HTML_FILE_NAME()
    {
        $htmlPath = './Html/' . Request::App(true) . "/" . Request::controller(true) . "/" . Request::action(true);
        $rule = substr(md5(Request::url(true)), 0, 2);
        if (Request::query()) {
            define('HTML_FILE_NAME', $htmlPath . "/" . $rule . "/" . md5(Request::url(true)) . "." . config("route.url_html_suffix"));
        } else {
            define('HTML_FILE_NAME', $htmlPath . "." . config("route.url_html_suffix"));
        }
    }

    // 初始化模板编译存储器
    private function initStorage()
    {
        $class = '\\think\\template\\driver\\File';
        return new $class();
    }

}